package org.dfl.core.model.transitions;


import org.dfl.core.data.types.Type;
import org.dfl.core.data.types.TypeManager;
import org.dfl.core.model.TransitionExecutionException;
import org.dfl.messages.Messages;


/**
 * transition to convert input value to a string
 * @author Piotr Wlodarczyk
 *
 */
public class ToStringTransition extends OneInputTransition {
	
	@Override
	public String getDefaultDescription() {
		return Messages.ToStringTransition_description;		
	}

	@Override
	protected void connectInputAndOutput() {
		// no connection - input=any, output is FIXED!
	}

	@Override
	protected Object fireSingle(Object input) throws TransitionExecutionException {
		return  input.toString().toLowerCase();
	}

	@Override
	protected Type getDefaultInputDefinition() {
		return TypeManager.getAnyType();
	}
	@Override
	protected Type getDefaultOutputDefinition() {
		return TypeManager.getStringType();
	}
}
